package com.tjsinfo.tjsoa.articles.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.articles.bo.IArticlesBO;
import com.tjsinfo.tjsoa.articles.bo.ManageSuperAction;
import com.tjsinfo.tjsoa.common.SessionUser;
import com.tjsinfo.tjsoa.common.ToolKit;
import com.tjsinfo.tjsoa.reminded.bo.TSystemRemindedManager;
import com.tjsinfo.tjsoa.reminded.vo.TSystemReminded;
import com.tjsinfo.tjsoa.system.bo.ITsystemRolesBo;
import com.tjsinfo.tjsoa.system.vo.User;
import com.tjsinfo.tjsoa.articles.bo.TArticlesUserManage;
import com.tjsinfo.tjsoa.articles.vo.TIndexArticles;

public class FirstAction extends ManageSuperAction {
	private IArticlesBO articlesBO;
	private String loginName;
	private TArticlesUserManage articlesUserManage;
	TSystemRemindedManager systemRemindedManager;
	
	public String getLoginName() {
		return loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}

//hanzhuo start
    public ITsystemRolesBo itrb;
	
	public ITsystemRolesBo getItrb() {
		return itrb;
	}

	public void setItrb(ITsystemRolesBo itrb) {
		this.itrb = itrb;
	}
	
	public void setTsystemRolesBo(ITsystemRolesBo itrb) {
		this.itrb = itrb;
	}
	
	public ITsystemRolesBo getTsystemRolesBo(ITsystemRolesBo itrb) {
		return itrb;
	}
	
//end	

	public IArticlesBO getArticlesBO() {
		return articlesBO;
	}

	public void setArticlesBO(IArticlesBO articlesBO) {
		this.articlesBO = articlesBO;
	}

	public TArticlesUserManage getArticlesUserManage() {
		return articlesUserManage;
	}

	public void setArticlesUserManage(TArticlesUserManage articlesUserManage) {
		this.articlesUserManage = articlesUserManage;
	}

	public TSystemRemindedManager getSystemRemindedManager() {
		return systemRemindedManager;
	}

	public void setSystemRemindedManager(
			TSystemRemindedManager systemRemindedManager) {
		this.systemRemindedManager = systemRemindedManager;
	}
	
	@SuppressWarnings("unchecked")
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		String url=request.getParameter("url");
		request.setAttribute("url", url);
		
		String loginname = "";
		Integer userid = 1;
		User user = SessionUser.getUser(request);
		if(null != user){
		userid = user.getUser_id();
		loginname = user.getUsername();
		}
		request.setAttribute("loginname", loginname);
	    
		//收到提醒
		List<TSystemReminded> relist=systemRemindedManager.findByRemind("idList", "%,"+userid+",%","memo", "%,"+loginname+"%");
		request.setAttribute("relist", String.valueOf(relist.size()));
		request.setAttribute("remindList", relist);
		
		//导航
		try {
			String menu=itrb.getMenuList(request,ToolKit.getSessionUser(request).getPermission());
			request.setAttribute("menu", menu);
			Integer count=itrb.getMenuCount(request,ToolKit.getSessionUser(request).getPermission());
			request.setAttribute("count", count);
		} catch (Exception e) {
			e.printStackTrace();
			request.setAttribute("Exception", e);
		}
		
		return mapping.findForward("ok");
	}
 
	
}
